import React, { useState } from "react";
import axios from "axios";
import "./style.scss";
import { login } from "../../store/user/userAction";
import store from "../../store";
const Index = () => {
  const [username, setUsername] = useState("");
  const [password, setPassword] = useState("");
  const handleLogin = async () => {
    const loginData = {
      username,
      password,
    };
    store.dispatch(login(loginData));
  };
  return (
    <div>
      <div className="login">
        <h2>用户登录</h2>
        <input
          type="text"
          placeholder="请输入用户名"
          value={username}
          onChange={(e) => setUsername(e.target.value)}
        />
        <input
          type="text"
          placeholder="请输入密码"
          value={password}
          onChange={(e) => setPassword(e.target.value)}
        />
        <button onClick={handleLogin}>登录</button>
      </div>
    </div>
  );
};

export default Index;
